<?php
    header('content-type:text/html;charset="utf-8"');
    $object = $_POST["object"];
    $link = mysqli_connect("localhost","root","root");
    if(!$link){
        echo "连接失败";
        exit; //结束后续操作
    }
    mysqli_set_charset($link,"utf8");
    mysqli_select_db($link,"租售系统");
    $sql = "SELECT * FROM goods";

    $res = mysqli_query($link,$sql);

    $arr = array();
    //7.处理结果集 
    if($res){
        while($row = mysqli_fetch_assoc($res)){
            array_push($arr,$row);
        }
        echo json_encode($arr);       
    }  
    mysqli_close($link);
?>